$(document).ready(function() {
    ai.autoHeight();
});
 

function loadRst() {
	
    var value = getCookie("tzpingce");
    var valueidstr = getCookie("tzpingce_id");
    if (value == "" || value == undefined) {
        alert("请先填写题目！");
        window.location = ctx+"/ha/phy/loadPhyIndex.do";
    }
    else { 
        $.ajax({
            type: "POST",
            url: ctx+"/ha/phy/loadPhyCaculation.do",
            data: "valuestr=" + value + '&idstr=' + valueidstr,
            success: function(msg) { 
                if (msg.split('$').length == 3) {
                    var outstr = "";
                    $(".tiZhi").empty();

                    var ztizhi = msg.split('$')[0];
                    outstr += "<tr><th class=\"font_red\">您的主要体质：</th><td class=\"main\">" + conversionimg(ztizhi) + "<div class=\"txt\">*点击图片即可查阅体质养生知识</div></td></tr>";

                    var jtizhi = msg.split('$')[1];
                    if (jtizhi != "") {
                        outstr += "<tr><th valign='top'>您的兼有体质：</th>";
                        outstr += "<td><ul>";
                        for (var i = 0; i < jtizhi.split(',').length; i++) {
                            if (jtizhi.split(',')[i] != "") {
                                outstr += "<li><a href=\"javascript:;\" onclick=\"show('" + jtizhi.split(',')[i] + "',0)\">" + conversion(jtizhi.split(',')[i]) + "</a></li>";
                            }
                        }
                        outstr += "</ul></td></tr>";
                    }

                    var qtizhi = msg.split('$')[2];
                    if (qtizhi != "") {
                        outstr += "<tr><th valign='top'>您的倾向体质：</th>";
                        outstr += "<td><ul>";
                        for (var i = 0; i < qtizhi.split(',').length; i++) {
                            if (qtizhi.split(',')[i] != "") {
                                outstr += "<li><a href=\"javascript:;\" onclick=\"show('" + qtizhi.split(',')[i] + "',0)\">" + conversion(qtizhi.split(',')[i]) + "</a></li>";
                            }
                        }
                        outstr += "</ul></td></tr>";
                    }

                    $(".tiZhi").append(outstr);

                }
               ai.autoHeight();
                $(".ContentBox").height(parseInt($(".CePing").height()) - 73);
            }
        });
    }
}

//计算
function calculation(typevalue, count) {
    return ((typevalue - count) / (count * 4)) * 100;
}

//题目名称
function conversion(value) {
    var outstr = "";
    switch (value) {
        case "yangxuzhi":
            outstr = "阳虚质";
            break;
        case "yinxuzhi":
            outstr = "阴虚质";
            break;
        case "qixuzhi":
            outstr = "气虚质";
            break;
        case "tanshizhi":
            outstr = "痰湿质";
            break;
        case "shirezhi":
            outstr = "湿热质";
            break;
        case "xuetanzhi":
            outstr = "血瘀质";
            break;
        case "tebingzhi":
            outstr = "特禀质";
            break;
        case "qiyuzhi":
            outstr = "气郁质";
            break;
        case "pinghezhi":
            outstr = "平和质";
            break;
        case "jibenpinghezhi":
            outstr = "基本平和质";
            break;
        default:
            break;
    }
    return outstr;
}

//控制按钮显示和外框架高度设置
function is_a_up() {
    var value = parseInt($("#topic_num").val().split("_")[0]);
    $(".test1").hide();
    $("#" + $("#topic_num").val()).show();
    if (value == 1) {
        $("#a_up").hide();
        $("#a_next").attr("class", "bn_nextCeshi");
    }
    if (value == 9) {
        $("#a_up").show();
        $("#a_next").attr("class", "bn_nextCeshi bn_chaKan");
    }
    if (value > 1 && value < 9) {
        $("#a_up").show();
        $("#a_next").attr("class", "bn_nextCeshi");
    }

    //设置外框架高度
   ai.autoHeight();
}

//输出图片
function conversionimg(n) {
    var outstr = "";
    switch (n) {
        case "yangxuzhi":
            outstr = "<a href=\"javascript:void(0)\"  class=\"YangXu\" onclick=\"show('" + n + "',0)\"></a>";
            break;
        case "yinxuzhi":
            outstr = "<a href=\"javascript:void(0)\"  class=\"YinXu\" onclick=\"show('" + n + "',0)\"></a>";
            break;
        case "qixuzhi":
            outstr = "<a href=\"javascript:void(0)\" class=\"QiXu\" onclick=\"show('" + n + "',0)\"></a>";
            break;
        case "tanshizhi":
            outstr = "<a href=\"javascript:void(0)\" class=\"TanShi\" onclick=\"show('" + n + "',0)\"></a>";
            break;
        case "shirezhi":
            outstr = "<a href=\"javascript:void(0)\" class=\"ShiRe\" onclick=\"show('" + n + "',0)\"></a>";
            break;
        case "xuetanzhi":
            outstr = "<a href=\"javascript:void(0)\" class=\"XueYu\" onclick=\"show('" + n + "',0)\"></a>";
            break;
        case "tebingzhi":
            outstr = "<a href=\"javascript:void(0)\"  class=\"TeLin\" onclick=\"show('" + n + "',0)\"></a>";
            break;
        case "qiyuzhi":
            outstr = "<a href=\"javascript:void(0)\"class=\"QiYu\" onclick=\"show('" + n + "',0)\"></a>";
            break;
        case "jibenpinghezhi":
        case "pinghezhi":
            outstr = "<a href=\"javascript:void(0)\"  class=\"PingHe\" onclick=\"show('" + n + "',0)\"></a>";
            break;
        default:
            break;
    }
    return outstr;
}

//图片点击弹出层效果
function show(phycode, type) {
    $.ajax({
        type:
        "POST",
        url: ctx+"/ha/phy/loadPhyAdvise.do",
        data: "phycode=" + phycode,
        success: function(msg) {
            $(".ContentBox").empty();
            $(".ContentBox").append(msg);
            $(".CePing").hide();
            $(".TanChuDiv").fadeIn(500);
            $(".YangSheng").empty();
            if (type == 1) {
               // $(".YangSheng").append("关于引起常见健康和美容问题的体质因素");
            }
            else {
                $(".YangSheng").append(conversion(phycode) + "养生说");
            }

        }
    });
}